<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>

	<title>GESTOR INCIDENCIAS</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link rel="stylesheet" type="text/css" href="css/menu.css">
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js"></script>
	
	<script src="js/menu.js"></script>
	<script src="js/comprobar_datos.js"></script>

</head>
<body>

<?php
require('php/cabecera.php');
?>
<script>
	
		function getAñadiraula(){
		
			var numero=document.getElementById("numero");
			
			var xmlhttp;
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp=new XMLHttpRequest();
                }
                else
                 {// code for IE6, IE5
                     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                 }
            xmlhttp.onreadystatechange=function()
             {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                 {
				  	
					document.getElementById("aviso").innerHTML=xmlhttp.responseText;  
					setInterval('location.reload()',500);             
                 }
				     	
			   }
        	
            xmlhttp.open("GET","php/insertarnuevoaula.php?numero="+numero.value,true);
            xmlhttp.send();
		
		}
	
	
	</script>
	<script>

	function comprobarAulas(){

	var num_aula = document.getElementById("numero");
	if (vacio(num_aula) == true){
                   num_aula.className = "error";
				   document.getElementById("aviso").innerHTML="<span style='color:red'>El campo está vacío</span>"; 
				   setInterval('location.reload()',2000);  
    }
	if (/^\d{3}$/.test(num_aula.value)) {
		num_aula.className = " ";
		getAñadiraula();
	}else{
		num_aula.className = "error";
		document.getElementById("aviso").innerHTML="<span style='color:red'>No has insertado 3 números</span>"; 
		setInterval('location.reload()',2000);  
	}
}
	</script>
	<script>
			(function($){
				
				//cache nav
				var nav = $("#topNav");
				
				//add indicator and hovers to submenu parents
				nav.find("li").each(function() {
					if ($(this).find("ul").length > 0) {
						/*$("<span>").text("^").appendTo($(this).children(":first"));*/

						//show subnav on hover
						$(this).mouseenter(function() {
							$(this).find("ul").stop(true, true).slideDown();
						});
						
						//hide submenus on exit
						$(this).mouseleave(function() {
							$(this).find("ul").stop(true, true).slideUp();
						});
					}
				});
			})(jQuery);
		</script>

<div id="contenido">
<?php
require('php/menuvotrasopciones.php');
?>
	
		<div id="principal">
			<h2><?php echo $xtitugestaula;?></h2>
			<div id="aulas">
				<div id="crearaulas">
					<h3><?php echo $xinsaula;?></h3>
					<form>
						<?php echo $xnumaula;?>: 
						<input type="text" id="numero"  maxlength="3" size="3"><br />
						<br />
						<input type="button" id="boton" value="<?php echo $xprovana;?>" onClick="comprobarAulas()" ><br />
					</form>
					<br />
					<div id="aviso">
					</div>
				</div>
				<div id="listaaulas">
					<?php
			
					require('php/conexionbd.php');
			
					echo '<form method="post" action="php/eliminaraula.php">
						<table>
						<tr>';
						$cont=0;
						$x=0;
						$res=mysql_query("select * from aulas",$con);
						while($row = mysql_fetch_array($res)){
							$id_aula=$row['id_aula'];
							$aula=$row['num_aula'];
							if($x==0){
								
									echo "<tr>";
								
							}
							if($cont%2==0){
								echo "<th class='fila_par'><input type='checkbox' name='casilla[]' value='".$id_aula."'></th>";
								echo "<th class='fila_par'>$aula</th>";
							}else{
								echo "<th class='fila_impar'><input type='checkbox' name='casilla[]' value='".$id_aula."'></th>";
								echo "<th class='fila_impar'>$aula</th>";
							}
							$x++;
							if($x==10){$x=0; echo "</tr>";}
							$cont++;
						}
						echo "</tr>";
						echo "</table>";
						echo "<input type='submit' value='$xelimaula' />";
					echo '</form>';
	
					?>
				</div>
            </div>
		</div>


</div>
	
	<div id="pie">
		<?php 
		include("pie.php");
		?>
	</div>
	
</body>
</html>